package o;

import androidx.annotation.NonNull;
import com.huawei.appgallery.foundation.apikit.control.DefaultImpl;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class cdc {
    private static Map<Class, Object> ˏ = new ConcurrentHashMap();

    public static Object ˋ(@NonNull Class cls) {
        if (cls == null) {
            Logger.e("InterfaceRegistry", "apiClass can not be null");
            return null;
        }
        Object obj = ˏ.get(cls);
        if (obj == null) {
            if (cls.isAnnotationPresent(DefaultImpl.class)) {
                DefaultImpl defaultImpl = (DefaultImpl) cls.getAnnotation(DefaultImpl.class);
                if (defaultImpl != null) {
                    try {
                        obj = defaultImpl.value().newInstance();
                        ˏ.put(cls, obj);
                        return obj;
                    } catch (Throwable e) {
                        Logger.ˋ("InterfaceRegistry", "instantiation default class failed", e);
                    } catch (Throwable e2) {
                        Logger.ˋ("InterfaceRegistry", "instantiation default class failed", e2);
                    }
                }
            }
        } else if (cls.isAssignableFrom(obj.getClass())) {
            return obj;
        }
        return null;
    }

    public static boolean ॱ(Class cls, ccy o_ccy) {
        if (cls == null) {
            Logger.e("InterfaceRegistry", "class is null.");
            return false;
        } else if (o_ccy == null) {
            Logger.e("InterfaceRegistry", "Impl is null.");
            return false;
        } else if (cls.isAssignableFrom(o_ccy.getClass())) {
            ˏ.put(cls, o_ccy);
            return true;
        } else {
            Logger.e("InterfaceRegistry", "Impl is not extends right class:" + cls + "-" + o_ccy.getClass());
            return false;
        }
    }
}
